package com.xbongbong.parent.parse.data;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.constant.MessageConstant;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.help.BusinessUserTeamHelp;
import com.xbongbong.paas.pojo.dto.AnalysisDataDTO;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.pojo.dto.ParseSingleRowDataDTO;
import com.xbongbong.paas.pojo.vo.LinkResultDataDTO;
import com.xbongbong.paas.pojo.vo.LinkResultDataVO;
import com.xbongbong.paas.pojo.vo.PaasFormDataEsListVO;
import com.xbongbong.paas.pojo.vo.ParseSingleRowDataVO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.BeanUtil;
import com.xbongbong.paas.toolbox.util.CollectionsUtil;
import com.xbongbong.paas.toolbox.util.StringUtil;
import com.xbongbong.paas.util.ItemUtil;
import com.xbongbong.parent.help.AnalysisTemplateFieldHelp;
import com.xbongbong.parent.interfaces.FormDataAnalysisDataService;
import com.xbongbong.pro.domain.entity.LabelEntity;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import com.xbongbong.pro.form.pojo.dto.FormConfigGetDTO;
import com.xbongbong.pro.label.pojo.LabelPojo;
import com.xbongbong.pro.onlineEditor.TemplateFieldValuePojo;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.constant.ParameterConstant;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.domain.entity.PublicGroupSeniorEntity;
import com.xbongbong.saas.enums.OperateTypeEnum;
import com.xbongbong.saas.enums.UserTeamEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.CustomerManagementEnum;
import com.xbongbong.saas.help.FormDataAnalysisHelp;
import com.xbongbong.saas.help.LabelHelp;
import com.xbongbong.saas.model.LabelModel;
import com.xbongbong.saas.model.PublicGroupSeniorModel;
import com.xbongbong.saas.service.toolbox.help.AnalysisSaasDataListHelp;
import com.xbongbong.saas.util.UserFieldUtil;
import com.xbongbong.sys.domain.entity.DepartmentEntity;
import com.xbongbong.sys.domain.entity.UserEntity;
import com.xbongbong.sys.model.DepartmentModel;
import com.xbongbong.sys.model.UserModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

/**
 * 此类虽然继承 FormDataListAnalysisDataHelp 但是最终的目的是替换掉com.xbongbong.parent.parse.data.FormDataListAnalysisDataHelp#analysisDataList(com.xbongbong.paas.pojo.dto.FormDataListDTO, com.xbongbong.paas.pojo.vo.PaasFormDataEsListVO)，主要作用是去除代码解析的多余代码，此方法只用于解析
 * @author 吴峰
 * @date 2022/05/16 16:32
 */
@Component
public abstract class AbstractListAnalysisDataService<D> extends FormDataListAnalysisDataHelp implements FormDataAnalysisDataService<PaasFormDataEntityExt> {

    private static final Logger LOG = LoggerFactory.getLogger(FormDataListAnalysisDataHelp.class);

    @Resource
    private AnalysisSaasDataListHelp analysisSaasDataListHelp;
    @Resource
    private FormDataFastUpdateAnalysisDataHelp formDataFastUpdateAnalysisDataHelp;
    @Resource
    private BusinessUserTeamHelp businessUserTeamHelp;
    @Resource
    private UserModel userModel;
    @Resource
    private DepartmentModel departmentModel;
    @Resource
    private LabelHelp labelHelp;
    @Resource
    private LabelModel labelModel;
    @Resource
    private FormDataLinkDataListServiceImpl formDataLinkDataListService;
    @Resource
    private PublicGroupSeniorModel publicGroupSeniorModel;
    @Resource
    private AnalysisTemplateFieldHelp analysisTemplateFieldHelp;

    /**
     * 解析数据
     * @param formDataListVO
     * @throws XbbException
     */
    @Override
    public void analysisDataList(FormDataListDTO formDataListDTO, PaasFormDataEsListVO formDataListVO) throws XbbException {
        List<PaasFormDataEntityExt> formDataList = analysisDataList(formDataListDTO, formDataListVO.getPaasFormDataESList(), formDataListVO.getHeadList());
        formDataListVO.setPaasFormDataESList(formDataList);
    }

    @Override
    public List<PaasFormDataEntityExt> analysisDataList(FormDataListDTO formDataListDTO, List<PaasFormDataEntityExt> formDataEsList, List<FieldAttrEntity> explainList) throws XbbException {
        try {

            List<Long> dataIdList = new ArrayList<>();
            Set<String> userIdList = UserFieldUtil.getUserIdList(formDataEsList, explainList, dataIdList);

            String corpid = formDataListDTO.getCorpid();

            //协同团队
            Map<Long, List<String>> mainUserMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
            Map<Long, List<String>> coUserMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
            Integer subBusinessType = formDataListDTO.getSubBusinessType();
            Integer businessType = formDataListDTO.getBusinessType();
            Map<Long, List<String>> paasCoUserMap = getUserTeamMap(userIdList, dataIdList, corpid, businessType, mainUserMap, coUserMap, subBusinessType);


            List<UserEntity> userEntityList = new ArrayList<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
            Map<String, Object> param = BeanUtil.convertBean2Map(formDataListDTO, true);
            param.remove("del");
//            param.put("del",0);
            param.put("userIdIn",userIdList);
            param.put(ParameterConstant.COLUMNS, "user_id, name");
            param.put(ParameterConstant.LEAVE_MARKS, BasicConstant.ONE);
            List<UserEntity> userList = userModel.findEntitys(param);
            userEntityList.addAll(userList);

            if(userEntityList == null) {
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, MessageConstant.USER_NOT_EXIST);
            }
            Map<String, UserEntity> userMap = new HashMap<>(userEntityList.size());
            userEntityList.forEach((item)->{
                userMap.put(item.getUserId(), item);
            });

            Map<String, DepartmentEntity> departmentMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);

            boolean departmentMapIsEmpty = hasDepartment(explainList);
            if(departmentMapIsEmpty){
                param.clear();
                param = BeanUtil.convertBean2Map(formDataListDTO, true);
                param.remove("del");
                param.put(ParameterConstant.COLUMNS, "id, name");
                List<DepartmentEntity> departmentList = departmentModel.findEntitys(param);
                if (departmentList == null) {
                    throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, MessageConstant.DEPT_NOT_EXIST);
                }
                departmentList.forEach((departmentItem) -> {
                    departmentMap.put(departmentItem.getId().toString(), departmentItem);
                });
            }
            Map<String, FieldAttrEntity> explainMap = new HashMap<>(explainList.size());
            for (FieldAttrEntity item : explainList) {
                explainMap.put(item.getAttr(), item);
            }

            LinkResultDataVO linkResultDataVO = new LinkResultDataVO();
            Set<Object> linkDataSet = new HashSet<>();
            List<PaasFormDataEntityExt> linkDataList = new ArrayList<>();



            FormConfigGetDTO formConfigGetDTO = new FormConfigGetDTO();
            formConfigGetDTO.setCorpid(corpid);
            formConfigGetDTO.setBusinessType(businessType);
            formConfigGetDTO.setFormId(formDataListDTO.getFormId());
            // 标签处理
            String labelAttr =null;
            for (FieldAttrEntity fieldAttrEntity : explainList) {
                if (Objects.equals(fieldAttrEntity.getFieldType(), FieldTypeEnum.LABEL.getType())) {
                    labelAttr = fieldAttrEntity.getAttr();
                    break;
                }
            }
            List<Long> labelIds = new ArrayList<>();
            if (StringUtil.isNotEmpty(labelAttr)){
                for (PaasFormDataEntityExt paasFormDataEntityExt : formDataEsList) {
                    Object o = null;
                    if(Objects.nonNull(paasFormDataEntityExt.getData().get(labelAttr))) {
                        o = paasFormDataEntityExt.getData().get(labelAttr);
                        List<Object> labelList = JSONArray.parseArray(o.toString(), Object.class);
                        if (CollectionsUtil.isNotEmpty(labelList)) {
                            for (Object labelId : labelList) {
                                //兼容存在脏数据UUID
                                if (Objects.nonNull(labelId) && !ItemUtil.isUUID(labelId.toString())) {
                                    labelIds.add(Long.valueOf(labelId.toString()));
                                }
                            }
                        }
                    }
                }
            }
            List<LabelEntity> byLabelIds = null;
            Map<Long, LabelEntity> labelMap= new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
            if (CollectionsUtil.isNotEmpty(labelIds)) {
                byLabelIds = labelModel.getByLabelIds(labelIds, corpid);
                byLabelIds.forEach(item->{
                    labelMap.put(item.getId(), item);
                });
            }

            Map<Long, LabelPojo> labelPojoMap = labelHelp.getLabelMap(formDataListDTO.getFormId(), formDataListDTO.getCorpid(), formDataListDTO.getAppId());
            Map<Long, PublicGroupSeniorEntity> publicGroupMap = publicGroupSeniorModel.getPublicGroupMap(formDataListDTO.getFormId(), formDataListDTO.getCorpid());
            Map<Object, TemplateFieldValuePojo> templateFieldMap = analysisTemplateFieldHelp.getTemplateFieldMap(corpid, explainList, formDataEsList);

            for (PaasFormDataEntityExt paasFormDataEsEntity: formDataEsList){
                JSONObject dataJsonObject = paasFormDataEsEntity.getData();
                if (Objects.nonNull(paasFormDataEsEntity.getOriginData())) {
                    dataJsonObject = paasFormDataEsEntity.getOriginData();
                    paasFormDataEsEntity.setOriginData(null);
                }
                dataJsonObject.put(FieldTypeEnum.ADDTIME.getAlias(), paasFormDataEsEntity.getAddTime());
                dataJsonObject.put(FieldTypeEnum.UPDATETIME.getAlias(), paasFormDataEsEntity.getUpdateTime());
                dataJsonObject.put(FieldTypeEnum.SERIALNO.getAlias(), paasFormDataEsEntity.getSerialNo());

                dataJsonObject.put(FieldTypeEnum.DEPARTMENTID.getAlias(), paasFormDataEsEntity.getDepartmentId());
                dataJsonObject.put(FieldTypeEnum.OWNERID.getAlias(), paasFormDataEsEntity.getOwnerId());

                ParseSingleRowDataDTO parseSingleRowDataDTO = new ParseSingleRowDataDTO();
                BeanUtil.copyProperties(formDataListDTO, parseSingleRowDataDTO);
                dataJsonObject.put(FieldTypeEnum.CREATORID.getAlias(), paasFormDataEsEntity.getCreatorId());
                // 设置创建人
                if (Objects.equals(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), businessType)) {
                    parseSingleRowDataDTO.setCreatorId(dataJsonObject.getString(CustomerManagementEnum.CREATOR.getAttr()));
                } else {
                    parseSingleRowDataDTO.setCreatorId(paasFormDataEsEntity.getCreatorId());
                }
                setOwnerIdAndCoUserId(businessType, dataJsonObject, parseSingleRowDataDTO, paasFormDataEsEntity, mainUserMap, coUserMap, paasCoUserMap);
                JSONObject cloneData = (JSONObject)dataJsonObject.clone();
                Long dataId = paasFormDataEsEntity.getId();
                paasFormDataEsEntity.setDataId(dataId);

                parseSingleRowDataDTO.setDataJsonObject(dataJsonObject);
                parseSingleRowDataDTO.setUserMap(userMap);
                parseSingleRowDataDTO.setDepartmentMap(departmentMap);
                parseSingleRowDataDTO.setExplainMap(getExplainMap(formDataListDTO, explainMap, paasFormDataEsEntity.getFormId()));
                parseSingleRowDataDTO.setListFlag(1);
                parseSingleRowDataDTO.setDataId(dataId);
                parseSingleRowDataDTO.setFormId(paasFormDataEsEntity.getFormId());
                parseSingleRowDataDTO.setPublicGroupMap(publicGroupMap);
                parseSingleRowDataDTO.setLabelPojoMap(labelPojoMap);
                parseSingleRowDataDTO.setTemplateFieldMap(templateFieldMap);
                // 解析单行数据
                ParseSingleRowDataVO parseSingleRowDataVO = parseSingleRowData(parseSingleRowDataDTO);
                if(Objects.isNull(parseSingleRowDataVO)){
                    throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, MessageConstant.PARSE_SINGLE_ROW_DATA_FAILED);
                }
                linkResultDataVO = parseSingleRowDataVO.getLinkResultDataVO();
                JSONObject resultObject = parseSingleRowDataVO.getResult();
                if (!linkResultDataVO.getLinkDataSet().isEmpty()) {
                    linkResultDataVO.getLinkDataSet().forEach((item -> {
                        linkDataSet.add(item);
                    }));
                }

                parseSingleRowDataDTO.setDataJsonObject(cloneData);
                // 为了在列表上面可以更新数据，加下这个
                ParseSingleRowDataVO updateDataVo = formDataFastUpdateAnalysisDataHelp.parseSingleRowData(parseSingleRowDataDTO);
                if(Objects.isNull(updateDataVo)){
                    throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, MessageConstant.PARSE_SINGLE_ROW_DATA_FAILED);
                }
                JSONObject sourceData = updateDataVo.getResult();

                sourceData.put(FieldTypeEnum.SERIALNO.getAlias(), paasFormDataEsEntity.getSerialNo());
                if (!sourceData.containsKey(FieldTypeEnum.DEPARTMENTID.getAlias())) {
                    sourceData.put(FieldTypeEnum.DEPARTMENTID.getAlias(), -1);
                }
                paasFormDataEsEntity.setSourceData(sourceData);
                explainList.forEach((item) -> {
                    if (!resultObject.containsKey(item.getAttr())) {
                        if (FieldTypeEnum.SUB_FORM.getType().equals(item.getFieldType())
                                || FieldTypeEnum.UPLOAD.getType().equals(item.getFieldType())
                                || FieldTypeEnum.IMAGE.getType().equals(item.getFieldType())
                                || FieldTypeEnum.CONTACT_NUMBER.getType().equals(item.getFieldType())) {
                            resultObject.put(item.getAttr(), new ArrayList<>());
                        } else {
                            resultObject.put(item.getAttr(), "");
                        }
                    }
                });


                paasFormDataEsEntity.setData(resultObject);

                // 系统字段经历过一次权限的判断，所以这里加下重新赋值
                paasFormDataEsEntity.setSerialNo(resultObject.getString(FieldTypeEnum.SERIALNO.getAlias()));
                paasFormDataEsEntity.setAddTime(resultObject.getLong(FieldTypeEnum.ADDTIME.getAlias()));
                paasFormDataEsEntity.setCreatorId(resultObject.getString(FieldTypeEnum.CREATORID.getAlias()));
                paasFormDataEsEntity.setUpdateTime(resultObject.getLong(FieldTypeEnum.UPDATETIME.getAlias()));
                paasFormDataEsEntity.setOwnerId(resultObject.getString(FieldTypeEnum.OWNERID.getAlias()));
                paasFormDataEsEntity.setAdvancePaymentBalance(paasFormDataEsEntity.getAdvancePaymentBalance());
                if (Objects.isNull(resultObject.get(FieldTypeEnum.DEPARTMENTID.getAlias()))) {
                    paasFormDataEsEntity.setDepartmentId(null);
                }

                linkDataList.add(paasFormDataEsEntity);
            }
            // 获取关联数据
            linkResultDataVO.setExplainMap(explainMap);
            linkResultDataVO.setUserMap(userMap);
            linkResultDataVO.setDepartmentMap(departmentMap);
            linkResultDataVO.setLinkDataSet(linkDataSet);
            linkResultDataVO.setFormDataList(linkDataList);
            linkResultDataVO.setExplainList(explainList);
            if(!linkDataSet.isEmpty()){
                LinkResultDataDTO linkResultDataDTO = new LinkResultDataDTO();
                BeanUtil.copyProperties(formDataListDTO, linkResultDataDTO);
                formDataLinkDataListService.formDataLinkDataGet(linkResultDataDTO, linkResultDataVO);
            }
            return linkResultDataVO.getFormDataList();
        } catch (XbbException e) {
            throw e;
        } catch (Exception e) {
            LOG.error("formDataListAnalysisDataHelp.analysisData表单列表解析数据出错", e);
            throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
        }

    }

    public Map<String, FieldAttrEntity> getExplainMap(FormDataListDTO formDataListDTO, Map<String, FieldAttrEntity> explainMap, Long formId) {
        return explainMap;
    }

    /**
     *  此方法重载com.xbongbong.parent.parse.data.FormDataListAnalysisDataHelp#analysisData(com.xbongbong.paas.pojo.dto.AnalysisDataDTO, com.alibaba.fastjson.JSONObject, java.util.Map, java.util.Set)，比其父类多几个字段类型的解析
     * @param analysisDataDTO
     * @param resultJsonObject
     * @param linkData
     * @param linkDataSet
     * @throws XbbException
     */
    @Override
    public void analysisData(AnalysisDataDTO analysisDataDTO, JSONObject resultJsonObject,
                             Map<String, Object> linkData, Set<Object> linkDataSet) throws XbbException {
        FieldAttrEntity fieldAttrEntity = analysisDataDTO.getFieldAttrEntity();
        String key = analysisDataDTO.getAttr();
        JSONObject objectJsonObject = analysisDataDTO.getDataJsonObject();
        if (Objects.isNull(analysisDataDTO.getIsProcess()) || !analysisDataDTO.getIsProcess()) {
            FormDataAnalysisHelp.invisibleSetNull(fieldAttrEntity, analysisDataDTO, objectJsonObject);
        }
        if (Objects.equals(FieldTypeEnum.LINK_BUSINESS_SINGLE.getType(), fieldAttrEntity.getFieldType()) && Objects.nonNull(objectJsonObject.get(key))) {
            // 系统业务单选
            String linkedText = fieldAttrEntity.getLinkedText();
            JSONObject jsonObject = new JSONObject();
            JSONArray jsonArray = new JSONArray();
            jsonObject.put(StringConstant.SAAS_LINK_BUSINESS_ID, objectJsonObject.getLong(key));
            jsonObject.put(StringConstant.SAAS_LINK_BUSINESS_NAME, objectJsonObject.getString(linkedText));
            jsonObject.put(StringConstant.SAAS_LINK_BUSINESS_LINK_TYPE, fieldAttrEntity.getLinkedType());
            jsonObject.put("saasMark", SaasMarkEnum.SAAS.getCode());
            jsonArray.add(jsonObject);
            resultJsonObject.put(key, jsonArray);
        } else if (Objects.equals(FieldTypeEnum.LINK_BUSINESS_MULTI.getType(), fieldAttrEntity.getFieldType()) && Objects.nonNull(objectJsonObject.get(key))) {
            // com.xbongbong.saas.service.toolbox.help.AnalysisSaasDataListHelp.analysisSaasData4Web->com.xbongbong.saas.service.toolbox.help.AnalysisSaasDataListHelp.formatListBusiness4Show
            // todo 后续如果实现应收款需要注意上面的方法，关联类型fieldAttrEntity.getLinkedType()需要变换
            // 系统业务多选
            String linkedText = fieldAttrEntity.getLinkedText();
            JSONArray businessIdList  = objectJsonObject.getJSONArray(fieldAttrEntity.getAttr()) == null ? new JSONArray() : objectJsonObject.getJSONArray(fieldAttrEntity.getAttr());
            JSONArray businessNameList = objectJsonObject.getJSONArray(linkedText) == null ? new JSONArray() : objectJsonObject.getJSONArray(linkedText);
            if (!businessIdList.isEmpty() && !businessNameList.isEmpty()) {
                JSONArray jsonArray = new JSONArray();
                for (int i = 0; i < businessIdList.size(); i++) {
                    Long businessId = businessIdList.getLong(i);
                    String businessName = "";
                    if (CollectionsUtil.isNotEmpty(businessNameList) && i < businessNameList.size()) {
                        businessName = businessNameList.getString(i);
                    } else {
                        continue;
                    }
                    JSONObject linkObject = new JSONObject();
                    linkObject.put(StringConstant.SAAS_LINK_BUSINESS_ID, businessId);
                    linkObject.put(StringConstant.SAAS_LINK_BUSINESS_NAME, businessName);
                    linkObject.put(StringConstant.SAAS_LINK_BUSINESS_LINK_TYPE,fieldAttrEntity.getLinkedType());
                    linkObject.put("saasMark", SaasMarkEnum.SAAS.getCode());
                    jsonArray.add(linkObject);
                }
                resultJsonObject.put(key, jsonArray);
            }
        } else if (Objects.equals(FieldTypeEnum.BIRTHDAY.getType(), fieldAttrEntity.getFieldType())) {
            String linkedText = fieldAttrEntity.getLinkedText();
            analysisSaasDataListHelp.formatBirthday4Show(objectJsonObject, key, linkedText);
            resultJsonObject.put(key, objectJsonObject.get(key));
        } else if (Objects.equals(FieldTypeEnum.SWITCH.getType(), fieldAttrEntity.getFieldType())) {
            if (Objects.equals(objectJsonObject.getString(key), BasicConstant.ZERO.toString())) {
                resultJsonObject.put(key, OperateTypeEnum.NO.getName());
            }else if (Objects.equals(objectJsonObject.getString(key), BasicConstant.ONE.toString())){
                resultJsonObject.put(key, OperateTypeEnum.YES.getName());
            }else {

            }
        } else if (Objects.equals(FieldTypeEnum.PUBLIC_GROUP.getType(), fieldAttrEntity.getFieldType())) {
            dealId2GroupName(fieldAttrEntity.getAttr(),resultJsonObject, analysisDataDTO.getPublicGroupMap());
        } else if (Objects.equals(FieldTypeEnum.LABEL.getType(), fieldAttrEntity.getFieldType())) {
            labelHelp.dealId2Pojo4One(fieldAttrEntity.getAttr(), resultJsonObject, analysisDataDTO.getLabelPojoMap());
        }else if(Objects.equals(fieldAttrEntity.getFieldType(), FieldTypeEnum.TEMPLATE_FIELD.getType())){
            analysisTemplateFieldHelp.analysisTemplateField4Map(resultJsonObject, fieldAttrEntity.getAttr(),analysisDataDTO.getTemplateFieldMap());
        }else {
            //todo 缺少千分位解析
            super.analysisData(analysisDataDTO, resultJsonObject, linkData, linkDataSet);
        }
    }

    protected Map<Long, List<String>>  getUserTeamMap(Set<String> userIdList, List<Long> dataIdList, String corpid, Integer businessType,  Map<Long, List<String>> mainUserIdMap,
                                  Map<Long, List<String>> coUserIdMap, Integer subBusinessType) throws XbbException {
        if (UserTeamEnum.hasTeam(businessType)){
            // 客户和线索已在子类实现
            businessUserTeamHelp.getUserIdMapSetShow(userIdList,dataIdList,corpid,businessType, false,mainUserIdMap, coUserIdMap, DelEnum.NORMAL.getDel());
            return new HashMap<>(BasicConstant.ZERO);
        } else {
            return businessUserTeamHelp.coUserMapShow(userIdList,dataIdList, corpid);
        }
    }

    private void dealId2GroupName(String groupAttr, JSONObject dataJsonObject, Map<Long, PublicGroupSeniorEntity> publicGroupSeniorMap) {
        if (publicGroupSeniorMap != null && publicGroupSeniorMap.size() > 0) {
            if (StringUtil.isNotEmpty(groupAttr)) {
                // 查询对应的标签
                String groupIdStr = dataJsonObject.getString(groupAttr);
                if (StringUtil.isNotEmpty(groupIdStr)) {
                    PublicGroupSeniorEntity publicGroupSeniorEntity = publicGroupSeniorMap.get(Long.valueOf(groupIdStr));
                    if (Objects.nonNull(publicGroupSeniorEntity)) {
                        dataJsonObject.put(groupAttr, publicGroupSeniorEntity.getName());
                    }
                }
            }
        }
    }
}
